package com.service.business.order.controller;

import com.service.business.framework.log.RequestLog;
import com.service.business.order.controller.rep.BaseOrderRep;
import com.service.business.order.controller.rep.OrderProductRep;
import com.service.business.order.controller.req.OrderProductOtherCreateReq;
import com.service.business.order.controller.req.OrderProductPageReq;
import com.service.business.order.service.OrderProductOtherService;
import com.service.core.rest.BaseController;
import com.service.core.rest.response.BaseResponse;
import com.service.core.rest.response.OneResponse;
import com.service.core.rest.response.PageResponse;
import com.service.dao.enums.ProductEnums;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <dl>
 * <dt>back-end</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年09月29日</dd>
 * </dl>
 *
 * @author
 */
@Slf4j
@RestController()
@RequestMapping("order-product-other")
@Api(tags = "订单接口")
public class OrderProductOtherController extends BaseController {

    @Autowired
    private OrderProductOtherService orderProductOtherService;

    @ApiOperation("创建订单:礼包")
    @RequestLog("创建订单:礼包")
    @PostMapping("create-order")
    public OneResponse<BaseOrderRep> orderProduct(@Validated @RequestBody OrderProductOtherCreateReq createReq) {
        return successQueryOneResponse(orderProductOtherService.orderProduct(createReq));
    }

    @ApiOperation("支付详情")
    @RequestLog("支付详情")
    @PostMapping("pay-detail/{orderNo}")
    public OneResponse<BaseOrderRep> payInfo(@PathVariable("orderNo") String orderNo) {
        return successQueryOneResponse(orderProductOtherService.getOrderPayInfo(orderNo));
    }


    @RequestLog("商城订单列表")
    @ApiOperation("商城订单列表")
    @PostMapping("list")
    public PageResponse<OrderProductRep> pointsOrderList(@ApiParam @RequestBody @Validated OrderProductPageReq request) {
        return successQueryPageResponse(orderProductOtherService.pageOrder(request));
    }

    @RequestLog("取消订单")
    @ApiOperation("取消订单")
    @PostMapping("cancel/{orderNo}")
    public BaseResponse cancelOrder(@ApiParam @PathVariable("orderNo") String orderNo) {
        orderProductOtherService.cancelOrder(orderNo);
        return successDeleteBaseResponse();
    }

    @RequestLog("订单详情")
    @ApiOperation("订单详情")
    @GetMapping("detail/{orderNo}")
    public OneResponse<OrderProductRep> detail(@ApiParam @PathVariable("orderNo") String orderNo) {
        return successQueryOneResponse(orderProductOtherService.orderDetail(orderNo));
    }

    @RequestLog("确认收货")
    @ApiOperation("确认收货")
    @PostMapping("sure/{orderNo}")
    public BaseResponse sure(@ApiParam @PathVariable("orderNo") String orderNo) {
        orderProductOtherService.sureReceive(orderNo);
        return successBaseResponse();
    }


}
